﻿// Implements functions to set a skin to an element
define([
    'Wjs/data/Loader'
],
function () {
    'use strict';

    return Wjs.defineOnce({

        type: 'Skinnable',

        internal: {

            initialize: function (cfg, parent) {

                cfg = cfg || {};

                if (cfg.skin) {

                    this.setSkin(cfg.skin);
                }

                this.onSkinChanged = cfg.onSkinChanged || this.onSkinChanged;
            }

        },

        skins: Wjs.createEnumeration({
            Red: 'red',
            Orange:'orange',
            Yellow:'yellow',
            Green: 'green',
            Blue: 'blue',
            Violet: 'violet'
        }),

        setSkin: function (name) {
            var old = this.skin;

            if (old) {

                this.replaceClass(old, name);
            }
            else {

                this.addClass(name);
            }

            this.skin = name;

            if (this.onSkinChanged) {

                this.onSkinChanged(name, old);
            }
        }

    });

});